<?php
ini_set('default_charset','utf-8');
include_once $_SERVER['DOCUMENT_ROOT'].'/lib/share.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/lib/jApi.php';

$API=jApi::inst( $_SERVER['DOCUMENT_ROOT'].'/conf/japi.geo.php' );
if($API->hasErrors())
  throw_error('API inicialization error ('. implode('->', $API->getErrors()) .')' ,500);

//DEFAULT WAY
if(!$API->run()) throw_error('API run error '.$API->getError(),500); exit();

/*
if(!$r=$API->post(
	'/point',
	array(
	  '_POST'=>array(
			'p_addr'=>'Киев, ул. Вербицкого, 18',
			'p_name'=>'Велика кишеня',
			'p_isNetwork'=>1,
			//'p_lat'=>50.423548,
			//'p_lng'=>30.446375
		)
	)
))
  echo '<pre class="debug">'.print_r ( $API->getErrors() ,true).'</pre>';
else
	echo 'result: <pre class="debug">'.print_r ( $r ,true).'</pre>';
exit();



include_once $_SERVER['DOCUMENT_ROOT'].'/lib/share.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/lib/Api.php';

$routes=include_once $_SERVER['DOCUMENT_ROOT'].'/conf/geo.router.php';
$apiGeo=API::inst($routes);

$apiGeo->setDBConf('/conf/db.geo.php');
$apiGeo->init();

//echo "Сделать миграцию ТТ из одной ТС в другую";
$apiGeo->run(); exit();

//$r=getApi()->invoke('/countries'); echo '<pre class="debug">'.print_r ( $r ,true).'</pre>'; exit();
//$r=$api->invoke('/country/UA','POST'); echo '<pre class="debug">'.print_r ( $r ,true).'</pre>'; exit();
$r=$apiGeo->invoke(
	'/country',
	'POST',
	array(
	  '_GET'=>array('lang'=>'ru','token'=>'tnX'),
	  '_POST'=>array( //'p_name','p_isNetwork','p_key_ctr','p_key_reg','p_key_cit','p_street','p_number'
			'ctr_name'=>'болгария',
		)
	)
);
echo '<pre class="debug">'.print_r ( $r ,true).'</pre>'; exit();


$r=$apiGeo->invoke(
	'/pointManual',
	'POST',
	array(
	  '_GET'=>array('lang'=>'ru','token'=>'tnX'),
	  '_POST'=>array( //'p_name','p_isNetwork','p_key_ctr','p_key_reg','p_key_cit','p_street','p_number'
			'ctr_id'=>'',
			'ctr_name'=>'',
			'reg_id'=>'',
			'reg_name'=>'',
			'cit_id'=>'',
			'cit_name'=>'',
			'ua_id'=>'',
			'ua_name'=>'',
			'p_street'=>'',
			'p_number'=>'',
			'p_name'=>'Реал маркет',
			'p_isNetwork'=>0,
			'net_id'=>'',
			'p_lat'=>50.423548,
			'p_lng'=>30.446375
		)
	)
);
echo '<pre class="debug">'.print_r ( $r ,true).'</pre>'; exit();

$r=$apiGeo->invoke(
	'/point',
	'POST',
	array(
	  '_GET'=>array('lang'=>'ru','token'=>'tnX'),
	  '_POST'=>array( //'p_name','p_isNetwork','p_key_ctr','p_key_reg','p_key_cit','p_street','p_number'
			'p_name'=>'Реал маркет',
			'p_isNetwork'=>0,
			//'p_addr'=>'Киев, харьковское шоссе 144Б',
			//'p_addr'=>'Севастополь, проспект Октябрьской Революции, 24'
			'p_lat'=>50.423548,
			'p_lng'=>30.446375
		)
	)
);
echo '<pre class="debug">'.print_r ( $r ,true).'</pre>'; exit();
*/
?>